package com.sunlg.smarthome.ui.wedget;

import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

import com.sunlg.smarthome.R;
import com.sunlg.smarthome.utils.DisplayUtils;

/**
 * Created by sunlg on 2017/2/25.
 */

public class WelcomeView extends View {

    private Paint mPaint;

    private float totalWidth = 300.0f;

    //绘制圆弧的进度值
    private int progress = 0;

    int step = 2;

    //线的宽度
    private int lineThick = 4;

    public WelcomeView(Context context) {
        super(context);
        init();
    }

    public WelcomeView(Context context, AttributeSet attrs) {
        super(context, attrs);

        totalWidth = DisplayUtils.dp2px(context, totalWidth);
        init();
    }

    public WelcomeView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }


    private void init() {
        mPaint = new Paint();
        mPaint.setAntiAlias(true);
        mPaint.setColor(Color.WHITE);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeWidth(lineThick);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawColor(getResources().getColor(R.color.colorPrimary));
        canvas.drawBitmap(BitmapFactory.decodeResource(getResources(), R.mipmap.smarthome),
                0,0,mPaint);

        //每隔6毫秒界面刷新
        postInvalidateDelayed(6);
    }
}
